import os.path, sqlite3
u = ''
p = ''

def prompt(x):
	print(x)
	global u
	global p
	u = raw_input("Username: ")
	p = raw_input("Password: ")
	p2 = raw_input("Repeat password: ")
	if(p!=p2):
		prompt("Error while inputing")

if(os.path.isfile(os.getcwd()+"\\scout.db")):
	exit()
else:
	print("--zScouting Server V0.1--")
	print("Created By: Zach Geis")
	print("--------------------------\n")
	print("Setting up zScouting Server")
	print("Creating database 'scout.db'")
	conn = sqlite3.connect('scout.db')
	c = conn.cursor()
	print("Database creation successful!")
	prompt("Enter admin account information:")
	print("Structuring database")
	
	#create database after this line
	c.execute('''create table users
		(username text, password text, groupid text)''')
	c.execute('''create table teams
		(Number text, Name text, Location text, Description text, MiniBot_YN text)''')
	c.execute('''create table matches
		(Number text, Location text, Randomness text)''')
	c.execute('''create table comps
		(Number text, Location text, Randomness text)''')
	
	print("Basic structure created!")
	c.execute("insert into users values ('"+u+"','"+p+"', 'admin')")
	print("Commiting changes to disk")
	conn.commit()
	print("Setup successful!")
	c.close()
	exit()
